from django.db import models


# Create your models here.


class User(models.Model):
    # 定义字段
    username = models.CharField(max_length=100, verbose_name='用户名', blank=True, null=True)
    phone = models.CharField(max_length=15, verbose_name='手机号', blank=True, null=True)
    password = models.CharField(max_length=100, verbose_name='密码', blank=True, null=True)
    red_phone = models.CharField(max_length=15, verbose_name='小红书号', blank=True, null=True)
    img = models.CharField(max_length=255, verbose_name='头像', default='')
    IP = models.GenericIPAddressField(verbose_name='IP', blank=True, null=True)
    intro = models.TextField(verbose_name='简介', default='有趣的简介可以吸引粉丝')
    sex = models.CharField(max_length=10, verbose_name='性别', blank=True, null=True)
    age = models.IntegerField(verbose_name='年龄', blank=True, null=True)
    birthday = models.DateField(verbose_name='生日', blank=True, null=True)
    job = models.CharField(max_length=100, verbose_name='职业', blank=True, null=True)
    school = models.CharField(max_length=100, verbose_name='学校', blank=True, null=True)
    address = models.CharField(max_length=255, verbose_name='地址', blank=True, null=True)
    is_show = models.BooleanField(default=True, verbose_name='是否展示')
    is_delete = models.BooleanField(default=False, verbose_name='是否删除')

    def __str__(self):
        return self.username

    class Meta:
        db_table = 'user'


class ThirdParty(models.Model):
    types = models.CharField(max_length=10, verbose_name='第三方类型', choices=(('1', 'QQ'), ('2', '微博'), ('3', '钉钉')), default=3)
    uid = models.CharField(max_length=50, verbose_name='第三方唯一标识')
    userid = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id')
    token = models.CharField(max_length=255, verbose_name='第三方token', blank=True, null=True)

    def __str__(self):
        return self.types

    class Meta:
        db_table = 'third_party'


class Identity(models.Model):
    name = models.CharField(max_length=10, verbose_name='姓名')
    identification = models.CharField(max_length=18, verbose_name='身份证号')
    image = models.CharField(max_length=200, verbose_name='图片', blank=True, null=True)
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户id', default=46)

    def __str__(self):
        return self.name

    class Meta:
        db_table = 'identity'
